package com.youyi.yypermissionlibrary.core.os;

import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

public class XiaoMi implements SettingPage {
    private static final String EXTRA_MIUI_PKG = "extra_pkgname";
    private static final String MIUI8_MAIN_CLS = "com.miui.securityscan.MainActivity";
    private static final String MIUI_ACTION = "miui.intent.action.APP_PERM_EDITOR";
    private static final String MIUI_COMMAND_VERSION = "getprop ro.miui.ui.version.name";
    private static final String MIUI_MAIN_CLS = "com.miui.permcenter.permissions.AppPermissionsEditorActivity";
    private static final String PKG = "com.miui.securitycenter";
    private Context context;

    public XiaoMi(Context context2) {
        this.context = context2;
    }

    /* JADX WARNING: Removed duplicated region for block: B:18:0x0038 A[SYNTHETIC, Splitter:B:18:0x0038] */
    /* JADX WARNING: Removed duplicated region for block: B:25:0x0044 A[SYNTHETIC, Splitter:B:25:0x0044] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private static String getSystemProperty() {
        /*
            r0 = 0
            java.lang.Runtime r1 = java.lang.Runtime.getRuntime()     // Catch:{ IOException -> 0x002e, all -> 0x002a }
            java.lang.String r2 = "getprop ro.miui.ui.version.name"
            java.lang.Process r1 = r1.exec(r2)     // Catch:{ IOException -> 0x002e, all -> 0x002a }
            java.io.BufferedReader r2 = new java.io.BufferedReader     // Catch:{ IOException -> 0x002e, all -> 0x002a }
            java.io.InputStreamReader r3 = new java.io.InputStreamReader     // Catch:{ IOException -> 0x002e, all -> 0x002a }
            java.io.InputStream r1 = r1.getInputStream()     // Catch:{ IOException -> 0x002e, all -> 0x002a }
            r3.<init>(r1)     // Catch:{ IOException -> 0x002e, all -> 0x002a }
            r1 = 1024(0x400, float:1.435E-42)
            r2.<init>(r3, r1)     // Catch:{ IOException -> 0x002e, all -> 0x002a }
            java.lang.String r0 = r2.readLine()     // Catch:{ IOException -> 0x0028 }
            r2.close()     // Catch:{ IOException -> 0x0023 }
            goto L_0x0027
        L_0x0023:
            r1 = move-exception
            r1.printStackTrace()
        L_0x0027:
            return r0
        L_0x0028:
            r0 = move-exception
            goto L_0x0031
        L_0x002a:
            r1 = move-exception
            r2 = r0
            r0 = r1
            goto L_0x0042
        L_0x002e:
            r1 = move-exception
            r2 = r0
            r0 = r1
        L_0x0031:
            r0.printStackTrace()     // Catch:{ all -> 0x0041 }
            java.lang.String r0 = ""
            if (r2 == 0) goto L_0x0040
            r2.close()     // Catch:{ IOException -> 0x003c }
            goto L_0x0040
        L_0x003c:
            r1 = move-exception
            r1.printStackTrace()
        L_0x0040:
            return r0
        L_0x0041:
            r0 = move-exception
        L_0x0042:
            if (r2 == 0) goto L_0x004c
            r2.close()     // Catch:{ IOException -> 0x0048 }
            goto L_0x004c
        L_0x0048:
            r1 = move-exception
            r1.printStackTrace()
        L_0x004c:
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.youyi.yypermissionlibrary.core.os.XiaoMi.getSystemProperty():java.lang.String");
    }

    @Override // com.youyi.yypermissionlibrary.core.os.SettingPage
    public Intent createIntent() throws ActivityNotFoundException {
        Intent intent = new Intent();
        String systemProperty = getSystemProperty();
        if (systemProperty.contains("7") || systemProperty.contains("6") || systemProperty.contains("5")) {
            intent = new Intent(MIUI_ACTION);
            intent.setComponent(new ComponentName(PKG, MIUI_MAIN_CLS));
            intent.putExtra(EXTRA_MIUI_PKG, this.context.getPackageName());
        } else {
            intent.putExtra(SettingPage.EXTRA_PKG, this.context.getPackageName());
            intent.setComponent(new ComponentName(PKG, MIUI8_MAIN_CLS));
        }
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        return intent;
    }
}
